package com.best;

import com.best.bean.Person;
import com.best.config.MainConfig;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml");
        Person bean = (Person) applicationContext.getBean("person");
        System.out.println(bean);

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MainConfig.class);
        Person bean1 = context.getBean(Person.class);
        System.out.println(bean1);

        String[] names = context.getBeanNamesForType(Person.class);
        for (String name : names) {
            System.out.println(name);
            System.out.println("********结束******");
        }

    }
}
